import App from "./App.vue";

// #ifndef VUE3
import Vue from 'vue'
import API from "api/api.js"
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import API from "api/api.js"
// 引入组件
import headerNew from "component/headerNew/headerNew.vue"
import Tooltip from "component/tooltip/tooltip.vue"
import None from "component/none/none.vue"
// import ElementUI from 'element-ui'
// import 'element-ui/lib/theme-chalk/index.css'
import 'styles/constom-elements.scss'

import { help } from "api/getNetWork.js";

//引入苹方字体
import 'static/font/font.css'
// 阿里云图标
import "static/icons/iconfont.css";

// 对屏幕份数的划分，这里设置为24份。（份数并不固定，这里是默认按1920px宽的分辨率进行设定）
function setRemUnit() {
  let width = document.documentElement.clientWidth || document.body.clientWidth;
  let rem = width / 24; //1920分辨率,屏幕分成24份 1rem=80px
  document.documentElement.style.fontSize = rem + "px";
}
setRemUnit();

// 动态修改根字体大小
function throttle(func) {
  let timer;
  if (timer) {
    clearTimeout(timer);
  }
  timer = setTimeout(() => {
    func()
  }, 300);
}
window.addEventListener("resize", ()=>{
  throttle(setRemUnit)
});


Vue.use(ElementUI, {
  size: 'medium',
  menuType: 'text'
})

import VueAMap from 'vue-amap';
// 引入地图
Vue.use(VueAMap);
Vue.use(ElementUI)
	if(uni.getStorageSync('mapKey')){
		window._AMapSecurityConfig = {
		  securityJsCode: uni.getStorageSync('mapHost') //安全密钥
		}
		// 初始化vue-amap
		VueAMap.initAMapApiLoader({
		  // 高德的key
		  key: uni.getStorageSync('mapKey'),
		  // 插件集合
		  plugin: [
		    'AMap.Autocomplete',
		    'AMap.Geocoder',
		    'AMap.Scale',
		    'AMap.Geolocation',
		    'MarkerClusterer',
		    "AMap.CircleMarker",
		    "AMap.PolyEditor", //编辑 折线多，边形
		    "AMap.Heatmap",
			  "Map3D"
		  ],
		  // 高德 sdk 版本，默认为 1.4.4
		  v: '1.4.15',
		  uiVersion: '1.1' // 版本号
		});
	}

// #ifdef H5
import indexedDB from "api/indexedDB.js";
// #endif
// #ifndef H5
import sqlite from "api/sqlite.js";
// #endif
Vue.config.productionTip = false;
// 注册全局组件
Vue.component('headerNew', headerNew)
Vue.component('Tooltip', Tooltip)
Vue.component('None', None)
// eventbus
Vue.prototype.$bus = new Vue();
// 请求封装
Vue.prototype.$api=API

Vue.prototype.$help = help;
// #ifdef H5
Vue.prototype.$indexedDB = indexedDB;
// #endif
// #ifndef H5
Vue.prototype.$sqlite = sqlite;
// #endif

App.mpType = "app";
Vue.use(ElementUI)
import './element-variables.scss'

App.mpType = 'app'
const app = new Vue({
  ...App,
});
app.$mount();
// #endif

// #ifdef VUE3
import { createSSRApp } from "vue";
export function createApp() {
  const app = createSSRApp(App);
  return {
    app,
  };
}
// #endif
